package com.smag.web.controller.farming;

import com.smag.common.annotation.Anonymous;
import com.smag.common.core.controller.BaseController;
import com.smag.common.core.domain.AjaxResult;
import com.smag.common.core.domain.entity.ArticleComment;
import com.smag.common.core.domain.entity.TechComment;
import com.smag.common.core.page.TableDataInfo;
import com.smag.system.service.CommentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/comment")
public class CommentController extends BaseController {
    @Resource
    private CommentService commentService;

    @GetMapping("/tech/commentList")
    public TableDataInfo getFarmTechCommentList(Integer pageNum,Integer pageSize,Long cropId){
//        startPage();
        return getDataTable(commentService.getTechCommentList(pageNum,pageSize,cropId));
    }

    @PostMapping("/tech")
    public AjaxResult sendCropComment(@RequestBody TechComment techComment){
        return commentService.sendCropComment(techComment);
    }

    @Anonymous
    @GetMapping("/commentList")
    public TableDataInfo getArticleCommentList(Long articleId, Integer pageNum, Integer pageSize) {
        return getDataTable(commentService.getArticleCommentList(pageNum,pageSize,articleId));
    }

    @PostMapping
    public AjaxResult sendArticleComment(@RequestBody ArticleComment articleComment){
        startPage();
        return commentService.sendArticleComment(articleComment);
    }

}
